﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;

namespace YJKArchUtils.Utils.Generics
{
	public class AngleComparer : IComparer<XYZ>
	{
		public AngleComparer(XYZ refPoint, XYZ center)
		{
			this.m_ReferencePoint = refPoint;
			this.m_Center = center;
		}

		public int Compare(XYZ pt1, XYZ pt2)
		{
			XYZ xyz = this.m_ReferencePoint - this.m_Center;
			XYZ xyz2 = pt1 - this.m_Center;
			XYZ xyz3 = pt2 - this.m_Center;
			double num = xyz.AngleOnPlaneTo(xyz2, XYZ.BasisZ);
			if (Math.Abs(num - Math.PI*2) < 1E-06)
			{
				num = 0.0;
			}
			double num2 = xyz.AngleOnPlaneTo(xyz3, XYZ.BasisZ);
			if (Math.Abs(num2 - Math.PI*2) < 1E-06)
			{
				num2 = 0.0;
			}
			return num.CompareTo(num2);
		}

		private XYZ m_ReferencePoint;

		private XYZ m_Center;
	}
}
